package com.dycx.api.controller.app.user;


import com.dycx.common.RestResponse;
import com.dycx.common.annotation.Authorization;
import com.dycx.common.context.UserInfoContext;
import com.dycx.user.dto.CommentDTO;
import com.dycx.user.enums.CommentStatusEnum;
import com.dycx.user.service.CommentService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;


/**
 * 评论(Comment)表控制层
 *
 * @author wuzongbin
 * @since 2023-12-29 10:53:24
 */
@RestController
@RequestMapping(value = "/app/user/comment")
public class CommentApiController {
    /**
     * 服务对象
     */
    @Resource
    private CommentService commentService;

    /**
     * 添加

     **/
    @Authorization
    @PostMapping("create")
    public RestResponse<Boolean> create(@RequestBody @Valid CommentDTO dto) {
        dto.setUid(UserInfoContext.get().getUserId());
        dto.setStatus(CommentStatusEnum.SUCCESS.getCode());
        return commentService.create(dto) ? RestResponse.success() : RestResponse.fail();
    }

}

